package cm.tidudada.support;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;


public class DynamicDataSourceContextHolder {

    // 当前当前线程存储dataSource key
    private static final ThreadLocal<String> dataSourceThreadLocal = new ThreadLocal<>();
    static {
        dataSourceThreadLocal.set("0");
    }

    // 存储所有的dataSource
    public static List<String> dataSourceKeys = new ArrayList<>();

    // 获取线程中的dataSource key
    public static String getDataSourceKey(){
        return dataSourceThreadLocal.get();
    }

    public static void setDataSourceKey(String key){
        dataSourceThreadLocal.set(key);
    }

    public static void deleteDataSourceKey(){
        dataSourceThreadLocal.remove();
    }












}
